<?php
/* @var $this QuestionController */
/* @var $model Question */
/* @var $form CActiveForm */

$cs = Yii::app()->clientScript;
$cs->registerCoreScript( 'jquery.ui' );
$cs->registerScriptFile(Yii::app()->theme->baseUrl . '/resources/js/answer.js', CClientScript::POS_BEGIN);
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'question-form',
	'enableAjaxValidation'=>false,
	'enableClientValidation'=>true,
	'clientOptions'=>
	array(
		'validateOnSubmit'=>true,
	),
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('size'=>80,'maxlength'=>512)); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'type'); ?>
		<?php echo $form->dropDownList($model, 'type', array('single_check' => 'Single Check', 'multi_check' => 'Multi Check', 'text' => 'Text')); ?>
		<?php echo $form->error($model,'type'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'is_mark'); ?>
		<?php echo $form->checkBox($model,'is_mark'); ?>
		<?php echo $form->error($model,'is_mark'); ?>
	</div>
	
	<fieldset class="answer">
		<legend>Answer</legend>
		<ul>
		<?php
			$answer = Answer::model()->getForEdit($model->id);
			foreach ($answer as $item){
				$this->renderPartial('/answer/item-answer', array('data' => $item));
			} 
		?>
		</ul>
		<a href="<?php echo Yii::app()->createUrl('//tracnghiem/question/addMoreAnswer') ?>" class="button" id="add_more">Add more</a>
	</fieldset>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->